package com.wn.manpower.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.Dimission;
import com.wn.entity.OfficeSupplies;
import com.wn.manpower.mapper.DimissionMapper;
import com.wn.manpower.mapper.OfficeSuppliesMapper;
import com.wn.manpower.service.DimissionService;
import com.wn.manpower.service.OfficeSuppliesService;
import com.wn.utils.PageBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author dzj
 * date: 2022/10/20
 */
@Service
public class OfficeSuppliesServiceImp implements OfficeSuppliesService {

    @Autowired
    private OfficeSuppliesMapper officeSuppliesMapper;

    @Override
    public void add(OfficeSupplies officeSupplies) {
        officeSuppliesMapper.add(officeSupplies);
    }

    @Override
    public void update(OfficeSupplies officeSupplies) {
        officeSuppliesMapper.update(officeSupplies);
    }

    @Override
    public void del(int id) {
        officeSuppliesMapper.del(id);
    }

    @Override
    public OfficeSupplies getById(int id) {
        return officeSuppliesMapper.getById(id);
    }

    @Override
    public PageBean<OfficeSupplies> getPageByCondition(OfficeSupplies officeSupplies, int currPage, int pageSize) {
        Page<Object> page = PageHelper.startPage(currPage, pageSize);
        List<OfficeSupplies> officeSupplies1 = officeSuppliesMapper.getByCondition(officeSupplies);
        PageBean<OfficeSupplies> pageBean = PageBeanUtil.getPageBean(officeSupplies1, page, currPage, pageSize);
        return pageBean;
    }
}
